<template>
	<view class="top_tab">
		<view :class="tabNum == index ? 'top_tab-ac' : ''" @click="changeTab(index)"
			v-for="(item,index) in tabs" :key="index">
			{{ item }}
		</view>
	</view>
</template>

<script>
	export default {
		name: "TopTab",
		props: {
      tabIndex:{
        default:0,
        type:Number|String
      },
			tabs: {
				default: () => [
					'待处理',
					'处理中'
				],
				type: Object | Array
			}
		},
		data() {
			return {
				tabNum: 0
			};
		},
		watch:{
			tabIndex(val){
				this.tabNum=val
			}
		},
    created() {
      this.tabNum=this.tabIndex
    },
    methods: {
			changeTab(index) {
				this.tabNum = index
				this.$emit("change", index)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.top_tab {
		width: 100vw;
		height: 90rpx;
		background: #ffffff;
		display: flex;
		justify-content: space-around;
		align-items: center;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		position: fixed;
		top: 0;
		/* #ifdef H5 */
		top: 80rpx;
		/* #endif */
		left: 0;
		z-index: 9;

		.top_tab-ac {
			display: flex;
			align-items: center;
			position: relative;
			height: 100%;
			font-weight: 500;

			&::after {
				position: absolute;
				content: "";
				bottom: 0;
				left: 50%;
				width: 30rpx;
				height: 6rpx;
				background: #6cc04e;
				border-radius: 4rpx;
				transform: translateX(-50%);
			}
		}
	}
</style>
